<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加/编辑用户 - Spring Boot 3.x + MyBatis Plus 示例</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <style>
        body {
            padding-top: 5rem;
        }
        .card {
            margin-bottom: 1.5rem;
        }
        .footer {
            margin-top: 3rem;
            padding: 1.5rem 0;
            border-top: 1px solid #eaeaea;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
        <div class="container">
            <a class="navbar-brand" href="/mybatis-plus/">Spring Boot 3.x + MyBatis Plus 示例</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/mybatis-plus/">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/mybatis-plus/user-management">用户管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/swagger-ui.html}" target="_blank">API文档</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/h2-console}" target="_blank">H2控制台</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <main class="container">
        <div class="row">
            <div class="col-md-8 offset-md-2">
                <div class="card">
                    <div class="card-header">
                        <h4 th:text="${user.id != null ? '编辑用户' : '添加用户'}"></h4>
                    </div>
                    <div class="card-body">
                        <form th:action="@{${user.id != null ? '/user-management/edit' : '/user-management/add'}}" method="post" th:object="${user}">
                            <input type="hidden" th:field="*{id}">
                            
                            <div class="mb-3">
                                <label for="username" class="form-label">用户名</label>
                                <input type="text" class="form-control" id="username" th:field="*{username}" required>
                            </div>
                            
                            <div class="mb-3">
                                <label for="password" class="form-label">密码</label>
                                <input type="password" class="form-control" id="password" th:field="*{password}" required>
                            </div>
                            
                            <div class="mb-3">
                                <label for="email" class="form-label">邮箱</label>
                                <input type="email" class="form-control" id="email" th:field="*{email}" required>
                            </div>
                            
                            <div class="mb-3">
                                <label for="phone" class="form-label">电话</label>
                                <input type="text" class="form-control" id="phone" th:field="*{phone}">
                            </div>
                            
                            <div class="mb-3" th:if="${user.id != null}">
                                <label for="status" class="form-label">状态</label>
                                <select class="form-control" id="status" th:field="*{status}">
                                    <option value="1">启用</option>
                                    <option value="0">禁用</option>
                                </select>
                            </div>
                            
                            <div class="d-flex justify-content-between">
                                <button type="submit" class="btn btn-primary">保存</button>
                                <a href="/mybatis-plus/user-management" class="btn btn-secondary">取消</a>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <footer class="footer bg-light">
        <div class="container text-center">
            <span class="text-muted">Spring Boot 3.x + MyBatis Plus 示例 &copy; 2024</span>
        </div>
    </footer>
</body>
</html>